package com.cate.mapper;

import com.cate.pojo.entity.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    @Delete("delete from address_book where id = #{id}")
    int delete(Long id);

    int insert(AddressBook record);

    @Select("select * from address_book where id = #{id}")
    AddressBook selectById(Long id);

    List<AddressBook> list(AddressBook record);

    int updateById(AddressBook record);

    /**
     * 根据 用户id修改 是否默认地址
     * @param addressBook
     */
    @Update("update address_book set is_default = #{isDefault} where user_id = #{userId}")
    void updateIsDefaultByUserId(AddressBook addressBook);
}
